﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Text;
using RN.ERP.Entity;
using RN.ERP.Entity.QD;
using RN.ERP.Entity.ResultModels;
using RN.ERP.DAL.Context;
using RN.ERP.Entity.ZBDLRY;
using Newtonsoft.Json;
using RN.ERP.DAL;
using RN.ERP.Entity.Authority;
using System.Reflection;
using Fly.FlyCommon;
using Fly.Log;

namespace RN.ERP.BLL
{
    public class BaseAuthorityBLL : IBll
    {
        protected DbContext baseContext;

        #region 角色管理 刘焕
        /// <summary>F
        /// 获取角色列表
        /// </summary>
        /// <param name="title">名称</param>
        /// <param name="code">编号</param>
        /// <param name="areacode">地区编号</param>
        /// <param name="description">描述</param>
        /// <returns></returns>
        public virtual List<DTO.T_Sys_Roles> GetRoles(string title, string code, string areacode, string description)
        {
            return null;
        }

        /// <summary>
        /// 根据角色GuID获取角色信息
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public virtual DTO.T_Sys_Roles GetRoleByGuId(Guid guid)
        {
            return null;
        }

        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult AddRole(DTO.T_Sys_Roles roleDTO)
        {
            return null;
        }

        /// <summary>
        /// 修改角色信息
        /// </summary>
        /// <param name="roleDTO"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult UpdateRole(DTO.T_Sys_Roles roles)
        {
            return null;
        }

        /// <summary>
        /// 根据角色Guid获取人员信息
        /// </summary>
        /// <param name="roleGuid">角色Guid</param>
        /// <returns></returns>
        public virtual List<DTO.Sys_Users> GetUserListByRoleGuid(Guid roleGuid)
        {
            return null;
        }

        /// <summary>
        /// 根据角色Guid和用户Guid删除用户的角色
        /// </summary>
        /// <param name="roleGuid">角色Guid</param>
        /// <param name="userGuid">用户Guid</param>
        /// <returns></returns>
        public virtual DTO.OperationResult DeleteByUserRole(string roleGuid, string userGuid)
        {
            return null;
        }

        /// <summary>
        /// 判断人员是否有角色
        /// </summary>
        /// <param name="roleGuid"></param>
        /// <param name="userGuid"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult GetUserRoleByUserRole(string roleGuid, string userGuid, string userID)
        {
            return null;
        }

        /// <summary>
        /// 根绝角色Guid获取人员角色表
        /// </summary>
        /// <param name="roleGuid"></param>
        /// <returns></returns>
        public virtual List<DTO.T_Sys_UserRole> GetUserRolesByRoleGuid(Guid roleGuid)
        {
            return null;
        }

        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="roleGuid"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult DeleteRole(string roleGuid)
        {
            return null;
        }

        public virtual List<DTO.T_Sys_Roles> GetRolesByUserGuid(string userGuid)
        {
            return null;
        }

        #endregion 角色管理

        #region 功能管理 蓝立明
        /// <summary>
        /// 功能更新
        /// </summary>
        /// <returns></returns>
        public virtual DTO.OperationResult UpdateFunction(DTO.T_Sys_Function function)
        {
            return null;
        }
        /// <summary>
        /// 获取功能列表
        /// </summary>
        /// <param name="code">编号</param>
        /// <param name="title">名称</param>
        /// <param name="appID">项目ID</param>
        /// <param name="parentGuid">父节点</param>
        /// <param name="rootGuid">根节点</param>
        /// <param name="isMenu">是否菜单</param>
        /// <param name="isDel">是否删除</param>
        /// <returns></returns>
        public virtual IList<DTO.T_Sys_Function> GetFunctionList(DTO.FuncQueryCondition condition)
        {
            return null;
        }

        /// <summary>
        /// 角色删除
        /// </summary>
        /// <returns></returns>
        public virtual DTO.OperationResult DeleteFunction(Guid funcGuid)
        {
            return null;
        }

        public virtual DTO.OperationResult AddFunction(DTO.T_Sys_Function function)
        {
            return null;
        }

        public virtual DTO.T_Sys_Function GetFunctionByGuid(Guid funcGuid)
        {
            return null;
        }

        public virtual IList<DTO.T_Sys_Function> GetMenuList(Guid userGuid, string appID)
        {
            return null;
        }

        /// <summary>
        /// 功能添加控件
        /// </summary>
        /// <param name="conFuncDTO"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult AddConFunction(DTO.T_Sys_ControlFunction conFuncDTO)
        {
            return null;
        }
        // 获取功能控件列表
        public virtual IList<DTO.T_Sys_ControlFunction> GetConFunctionList(Guid funcGuid)
        {
            return null;
        }

        //操作功能控件列表
        public virtual DTO.OperationResult OperateConFunction(Guid funcGuid, Guid conGuid, DTO.OperationType type)
        {
            return null;
        }
        #endregion

        #region 用户角色管理 作者：孙正滨
        //获取企业列表(绑定到下拉菜单)
        public virtual List<DTO.T_Sys_Users> GetUserList(string corpName, string username)
        {
            return null;
        }

        public virtual DTO.OperationResult SetUserRole(Guid userGuid, string roleNum, string roleArea)
        {
            return null;
        }

        // 获取角色列表
        public virtual List<DTO.T_Sys_UserRole> GetUserRoles(Guid userGuid)
        {
            return null;
        }

        // 获取用户角色列表
        public virtual List<DTO.T_Sys_UserRole> GetUserRolesList(Guid userGuid, Guid roleGuid)
        {
            return null;
        }

        /// <summary>
        /// 根据用户角色ID获取用户角色信息
        /// </summary>
        /// <param name="id">用户角色ID</param>
        /// <returns></returns>
        public virtual DTO.T_Sys_UserRole GetUserRoleById(int id)
        {
            return null;
        }

        /// <summary>
        /// 根据用户角色Guid获取用户角色信息
        /// </summary>
        /// <param name="guid">用户角色Guid</param>
        /// <returns></returns>
        public virtual DTO.T_Sys_UserRole GetUserRoleByGuId(Guid roleGuid)
        {
            return null;
        }

        /// <summary>
        /// 给用户分配角色
        /// </summary>
        /// <param name="userGuid">用户GUID</param>
        /// <param name="roleGuid">角色GUID</param>
        /// <param name="userID">添加人GUID</param>
        /// <returns></returns>
        public virtual DTO.OperationResult AddUserRole(DTO.T_Sys_UserRole userRoleDTO)
        {
            return null;
        }

        /// <summary>
        /// 修改用户角色信息
        /// </summary>
        /// <param name="id">用户角色信息ID</param>
        /// <param name="roleGuid">角色GUID</param>
        /// <param name="userID">添加人GUID</param>
        /// <returns></returns>
        public virtual DTO.OperationResult UpdateUserRole(DTO.T_Sys_UserRole userRoleDTO)
        {
            return null;
        }

        /// <summary>
        /// 删除用户角色
        /// </summary>
        /// <param name="roleID">角色ID或角色GUID</param>
        /// <param name="type">0:通过ID,1:通过Guid</param>
        /// <returns></returns>
        public virtual DTO.OperationResult DeleteUserRole(string roleGuid, string userGuid)
        {
            return null;
        }
        #endregion

        #region 分配功能权限 刘焕
        /// <summary>
        /// 给用户或角色分配功能
        /// </summary>
        /// <param name="funcDTO"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult AddFuncPermission(DTO.T_Sys_FuncPermission funcDTO)
        {
            return null;
        }

        /// <summary>
        /// 根据功能Guid和人员或角色Guid删除关联
        /// </summary>
        /// <param name="funcGuid">功能Guid</param>
        /// <param name="objGuid">人员或角色Guid</param>
        /// <returns></returns>
        public virtual DTO.OperationResult DelFuncPermission(Guid funcGuid, Guid objGuid)
        {
            return null;
        }

        /// <summary>
        /// 根据角色(人员)Guid获取权限
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="type">角色(人员)Guid</param>
        /// <returns></returns>
        public virtual List<DTO.T_Sys_FuncPermission> GetFuncPermission(Guid guid, string appid)
        {
            return null;
        }

        /// <summary>
        /// 根据功能Guid和角色（人员）Guid判断是否添加该功能
        /// </summary>
        /// <param name="objGuid"></param>
        /// <param name="funcGuid"></param>
        /// <param name="userID"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult GetFuncByFuncObj(string objGuid, string funcGuid, string userID)
        {
            return null;
        }

        /// <summary>
        /// 根据用户Guid和功能Guid 检测该用户是否存在此功能 --孙正滨
        /// </summary>
        /// <param name="userGuid">用户Guid</param>
        /// <param name="funcGuid">功能Guid</param>
        /// <returns></returns>
        public virtual DTO.OperationResult CheckFuncByUserGuid(string userGuid, string funcGuid)
        {
            return null;
        }

        /// <summary>
        /// 根据角色(人员)Guid获取权限 --孙正滨
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="type">人员Guid</param>
        /// <returns></returns>
        public virtual List<DTO.T_Sys_FuncPermission> GetFuncListByUserGuid(Guid guid)
        {
            return null;
        }

        /// <summary>
        /// 根据人员Guid判断是否添加该功能 -- 孙正滨
        /// </summary>
        /// <param name="objGuid">用户GUID</param>
        /// <param name="funcGuid">功能GUID</param>
        /// <param name="userID">添加人GUID</param>
        /// <returns></returns>
        public virtual DTO.OperationResult ChechFuncByFuncObj(string objGuid, string funcGuid, string userID)
        {
            return null;
        }
        #endregion

        #region 控件管理
        /// <summary>
        /// 获取控件列表
        /// </summary>
        /// <param name="title"></param>
        /// <param name="method"></param>
        /// <param name="clientlMethod"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public virtual List<DTO.T_Sys_Control> GetControls(string title, string method, string clientlMethod, string description)
        {
            return null;
        }

        /// <summary>
        /// 根据控件guid获取控件信息
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public virtual DTO.T_Sys_Control GetControlByGuId(Guid guid)
        {
            return null;
        }
        /// <summary>
        /// 根据功能Guid获取该功能对应Control
        /// </summary>
        /// <param name="funguid"></param>
        /// <returns></returns>
        public virtual List<DTO.T_Sys_Control> GetControlByFunGuid(Guid funguid)
        {
            return null;
        }
        /// <summary>
        /// 添加控件
        /// </summary>
        /// <param name="controlDTO"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult AddControl(DTO.T_Sys_Control controlDTO)
        {
            return null;
        }

        /// <summary>
        /// 修改控件信息
        /// </summary>
        /// <param name="controlDTO"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult UpdateControl(DTO.T_Sys_Control controlDTO)
        {
            return null;
        }

        /// <summary>
        /// 删除控件
        /// </summary>
        /// <param name="controlGuid"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult DeleteControl(string controlGuid)
        {
            return null;
        }

        public virtual List<DTO.GuidKeyAndValue> GetFunction()
        {
            return null;
        }
        #endregion

        #region 添加日志
        /// <summary>
        /// 插入记录
        /// </summary>
        /// <param name="content"></param>
        /// <param name="objectid"></param>
        /// <param name="user"></param>
        //private void InsertUserLog(string content, string objectid, DTO.UserPermission user)
        //{

        //}
        #endregion

        #region UC控件调用
        public virtual List<DTO.tb_Emp_TitleType> GetPsnQualLevelByType(int nid)
        {
            return null;
        }
        #endregion UC控件调用

        protected virtual List<DTO.T_Sys_Function> GetUserFunctionsInternal(string userGuid, string functionGuid, bool isMenu, string appId)
        {
            return null;
        }

        public virtual int GetUserCount(string corpName)
        {
            return 0;
        }

        public virtual DTO.OperationResult CheckPermission(string funcGuid, string objGuid, int funcType, int type, bool ischeck)
        {
            return null;
        }

        public virtual List<DTO.T_Sys_Function> GetUserFunctions(string userGuid, string functionGuid, string appId)
        {
            return null;
        }

        public virtual List<DTO.T_Sys_Control> GetUserControls(string userGuid, string functionGuid, string appId)
        {
            return null;
        }

        public virtual List<DTO.T_Sys_Function> GetUserMenus(string userGuid, string functionGuid, string appId)
        {
            return null;
        }

        public virtual List<DTO.T_Sys_Function> GetRoleFunctions(string roleGuid, string functionGuid, string appId)
        {
            return null;
        }

        public virtual List<string> GetUserFuncCodes(string userGuid, bool isMenu, string appId)
        {
            return null;
        }

        public virtual bool IsExistFunc(int id, string code)
        {
            return false;
        }

        public virtual List<DTO.T_Sys_FuncPermission> GetFuncPermissionForUser( Guid userGuid, string appid)
        {
            return null;
        }

        public virtual bool SaveorUpdateFuncPermissionForUser( Guid userGuid, string appid, List<string> addFuncs)
        {
            return false;
        }

        #region MyRegion
        /// <summary>
        /// 获取系统程序
        /// </summary>
        /// <returns></returns>
        public virtual List<DTO.T_Sys_Application> GetSysApp()
        {
            return null;
        }

        /// <summary>
        /// 获取用户和系统的关系
        /// </summary>
        /// <param name="corpGuid"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public virtual List<DTO.T_Sys_FuncPermission> GetUserSysPermission(string userGuid, int type)
        {
            return null;
        }

        /// <summary>
        /// 更行关系表IsDel
        /// </summary>
        /// <param name="funcDTO"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult UpdatePermission(DTO.T_Sys_FuncPermission funcDTO)
        {
            return null;
        }



        #endregion

        public virtual DTO.OperationResult AddPageMapping(DTO.FuncPageMapping page)
        {
            return null;
        }

         #region 部门管理
        /// <summary>
        /// 获取dict_Department中的数据 
        /// </summary>
        /// <param name="AreaCode"></param>
        /// <returns></returns>
        public virtual List<dict_Department> GetDepartmentData(string AreaCode)
        {
            return null;
        }

        /// <summary>
        /// 添加部门
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult AddDepartment(DTO.dict_Department dept)
        {
            return null;
        }

        /// <summary>
        /// 修改部门
        /// </summary>
        /// <param name="roleDTO"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult UpdateDepartment(DTO.dict_Department dept)
        {
            return null;
        }

        /// <summary>
        /// 删除部门
        /// </summary>
        /// <param name="roleGuid"></param>
        /// <returns></returns>
        public virtual DTO.OperationResult DeleteDepartment(int id)
        {
            return null;
        }

        #endregion
    }
}
